package com.hu.zhcc.shiro.service.Responsitory;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.REvaluateMapper;
import com.hu.zhcc.shiro.entity.Reponsitory.REvaluate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EvaluateServiceImpl implements EvaluateService {

    @Autowired
    private REvaluateMapper rEvaluateMapper;

    @Override
    public Page<REvaluate> selectAll(Map<String, String> map, REvaluate evaluate) {
        Integer pageIndex = Integer.valueOf(map.get("pageIndex"));
        Integer num = Integer.valueOf(map.get("num"));
        PageHelper.startPage(pageIndex, num);
        List<REvaluate> rEvaluates = rEvaluateMapper.selectAll(evaluate);
        PageInfo<REvaluate> pageInfo = new PageInfo<>(rEvaluates);
        return new Page<REvaluate>(pageInfo.getTotal(), rEvaluates);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return rEvaluateMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(REvaluate record) {
        return rEvaluateMapper.insertSelective(record);
    }

    @Override
    public REvaluate selectBeforeUpdate(int id) {
        return rEvaluateMapper.selectBeforeUpdate(id);
    }

    @Override
    public int updateByPrimaryKeySelective(REvaluate record) {
        return rEvaluateMapper.updateByPrimaryKeySelective(record);
    }
}
